#include "XMLElement.h"

#include "XMLAttribute.h"

#ifdef _DEBUG
#include <Windows.h>
#include "boost/foreach.hpp"
#endif

namespace XMLSAX
{
	namespace Common
	{
		XMLElement::XMLElement()
		{

		}

		XMLElement::~XMLElement()
		{

		}

		const std::wstring& XMLElement::Name() const
		{
			return _elementName;
		}

		void XMLElement::SetName( const std::wstring& name )
		{
			_elementName = name;
		}

		const std::wstring& XMLElement::Value() const
		{
			return _elementChars;
		}

		void XMLElement::SetValue( const std::wstring& value )
		{
			_elementChars = value;
		}

		const std::vector<XMLAttribute *>& XMLElement::Attributes() const
		{
			return _elementAttributes;
		}

		std::vector<XMLAttribute *>& XMLElement::accessAttributes()
		{
			return _elementAttributes;
		}

		void XMLElement::AddAttribute( XMLAttribute *attribute )
		{
			if(attribute != NULL)
				_elementAttributes.push_back(attribute);
		}

#ifdef _DEBUG
		void XMLElement::printElement()
		{
			OutputDebugString(L"Printing an XMLElement:\n");
			OutputDebugString(L"   Name: ");
			OutputDebugString(this->Name().data());
			OutputDebugString(L"\n");
			OutputDebugString(L"   Value: ");
			OutputDebugString(this->Value().data());
			OutputDebugString(L"\n");

			BOOST_FOREACH(XMLAttribute *attr, this->_elementAttributes)
			{
				attr->printAttribute();
			}
		}
#endif
	}
}